home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / gfx / conv / CreateIndex.lha / Convert2PNG16BW.isrx < prev    next >
Text File  |  1997-11-19  |  3KB  |  124 lines

  1. /* ImageStudio ARexx script **************************************/
  2.  
  3. /* Allow commands to return results */
  4.  
  5. options results
  6.  
  7. /* On error, goto ERROR:. Comment out this line if you wish to */
  8. /* perform your own error checking. */
  9.  
  10. signal on error
  11.  
  12. /* BEGIN PROGRAM *************************************************/
  13.  
  14. /* Warn the user if they are about to overwrite their current project */
  15.  
  16. IMAGEINFO_GET STEM imageinfo.
  17.  
  18. if imageinfo.changed == 1 then
  19.    REQUEST_MESSAGE TEXT '"Project has changed, continue?"',
  20.       BUTTONTEXT '"OK|Cancel"' AUTOCANCEL
  21.  
  22. /* get src files */
  23. REQUEST_MULTIFILE TITLE '"Choose source files..."' STEM srcfiles.
  24.  
  25. /* Loop around and convert all the files */
  26.  
  27. do l = 0 to (srcfiles.files.count - 1)
  28.    /* Open the file */
  29.  
  30.    OPEN FILE '"'srcfiles.files.l'"' FORCE
  31.  
  32.    /* Change colours to 16 shades from black to white */
  33.    COLOURS 16
  34.  
  35.    PALETTE_GET STEM oldpal
  36.  
  37.    newpal=''
  38.  
  39.    do c=0 to 15
  40.       do i=0 to 2
  41.          newpal=newpal||' '17*c
  42.       end
  43.    end
  44.  
  45.    PALETTE_SET PALETTE newpal REMAP
  46.  
  47.  
  48.    /* Create the output filename */
  49.  
  50.    FILE_SPLIT FILE '"'srcfiles.files.l'"' STEM filesplit.
  51.  
  52.    filename=left(filesplit.filepart,index(filesplit.filepart,'.')-1)
  53.  
  54.    FILE_JOIN PATHPART '"'filesplit.pathpart'"',
  55.       FILEPART '"'filename'.png"' VAR 'destfile'
  56.  
  57.    /* Save the fileout in the new format */
  58.  
  59.    SAVE FILE '"'destfile'"' FORMAT 'PNG' FORCE
  60.  
  61. end
  62.  
  63.  
  64. /* END PROGRAM ***************************************************/
  65.  
  66. exit
  67.  
  68. /* On ERROR */
  69.  
  70. ERROR:
  71.  
  72. /* If we get here, either an error occurred with the command's */
  73. /* execution or there was an error with the command itself. */
  74. /* In the former case, rc2 contains the error message and in */
  75. /* the latter, rc2 contains an error number. SIGL contains */
  76. /* the line number of the command which caused the jump */
  77. /* to ERROR: */
  78.  
  79. if datatype(rc2,'NUMERIC') == 1 then do
  80.    /* See if we can describe the error with a string */
  81.  
  82.    select
  83.       when rc2 == 103 then
  84.          err_string = "ERROR 103, "||,
  85.             "out of memory at line "||SIGL
  86.       when rc2 == 114 then
  87.          err_string = "ERROR 114, "||,
  88.             "bad command template at line "||SIGL
  89.       when rc2 == 115 then
  90.          err_string = "ERROR 115, "||,
  91.             "bad number for /N argument at line "||SIGL
  92.       when rc2 == 116 then
  93.          err_string = "ERROR 116, "||,
  94.             "required argument missing at line "||SIGL
  95.       when rc2 == 117 then
  96.          err_string = "ERROR 117, "||,
  97.             "value after keywork missing at line "||SIGL
  98.       when rc2 == 118 then
  99.          err_string = "ERROR 118, "||,
  100.             "wrong number of arguments at line "||SIGL
  101.       when rc2 == 119 then
  102.          err_string = "ERROR 119, "||,
  103.             "unmatched quotes at line "||SIGL
  104.       when rc2 == 120 then
  105.          err_string = "ERROR 120, "||,
  106.             "line too long at line "||SIGL
  107.       when rc2 == 236 then
  108.          err_string = "ERROR 236, "||,
  109.             "unknown command at line "||SIGL
  110.       otherwise
  111.          err_string = "ERROR "||rc2||", at line "||SIGL
  112.       end
  113.         end
  114. else if rc2 == 'RC2' then do
  115.    err_string = "ERROR in command at line "||SIGL
  116.    end
  117. else do
  118.         err_string = rc2||", line "||SIGL
  119.         end
  120.  
  121. request_message TEXT '"'err_string'"'
  122.  
  123. exit
  124.